<template>
  <div class="container">
    <salaryTopTitle
      @gobackTriser="toSalaryList"
      v-if="wherePage == 'fj'"
      :salaryOperate="salaryOperate"
      :salaryExcel="salaryExcel"
    ></salaryTopTitle>
    <salaryTopTitle @gobackTriser="toSalaryList" v-else></salaryTopTitle>
    <!-- <createSalaryStepJz :activeIndex="activeIndex"></createSalaryStepJz> -->
    <!--支付信息-->
    <div class="mainCon">
      <createSalaryStepJz :activeIndex="activeIndex"></createSalaryStepJz>
      <div class="vessel">
        <!-- <p>
          <i class="icon iconfont iconwancheng"></i>
        </p>-->
        <p class="reportTitle">
          <i class="icon iconfont iconyiqueren"></i>上报成功，请授权发工资
        </p>
        <div class="top-title">
          <el-link
            type="primary"
            @click="downloaDauthorizationForm"
            class="downloaDauthorizationForm"
            >下载工资代发授权单</el-link
          >
        </div>

        <div id="authorizationSheet" v-if="!ifFJ">
          <table class="top-left">
            <tr>
              <td colspan="2" class="sheetTitle">工资发放授权单</td>
            </tr>
            <tr>
              <td colspan="2" class="clearfix">
                <div class="tr-left">
                  <p>{{ offinePayDate.salaryInfo }}</p>
                  <div v-if="isEsUser()" class="tr-left-tip">
                    订单生成时间：{{ offinePayDate.createTime || '--' }}
                  </div>
                  <p>{{ offinePayDate.orderId }}</p>
                </div>
                <div class="tr-right">
                  <div class="tr-right-top clearfix">
                    <div class="tr-right-code fl">
                      <img class="srcCodeImg" :src="srcCode" alt />
                    </div>
                    <div class="tr-right-barCode fl">
                      <img class="barCodeCodeImg" :src="barCode" alt />
                    </div>
                  </div>
                  <div class="tr-right-tip">
                    提示：通过扫描二维码或条形码可快捷获取工资表订单
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="2" class="projectInformation">项目信息</td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                项目名称：{{ offinePayDate.projectName || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                建设方：{{ offinePayDate.pcName || '--' }}
              </td>
            </tr>
            <tr>
              <td class="tdLeft">施工方：{{ offinePayDate.pbName }}</td>
              <td class="tdLeft">
                施工方法人姓名：{{ offinePayDate.companyBoss || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                项目负责人姓名：{{ offinePayDate.projectAdmin || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                项目地址：{{ offinePayDate.address || '--' }}
              </td>
            </tr>
            <tr>
              <td class="tdLeft">
                专户账号：{{ offinePayDate.account || '--' }}
              </td>
              <td class="tdLeft">
                代发总人数：{{ offinePayDate.shouldCount || '--' }}人
              </td>
            </tr>
            <tr>
              <template v-if="isEsUser()">
                <td class="tdLeft">
                  专户签约状态：<span
                    :style="offinePayDate.signed === 0 ? 'color:red' : ''"
                    >{{
                      offinePayDate.signed === 1 ? '已签约' : '未签约'
                    }}</span
                  >
                </td>
                <td class="tdLeft">
                  代发总金额：{{ offinePayDate.shouldPay || '--' }}元
                </td>
              </template>
              <template v-else>
                <td colspan="2" class="tdLeft">
                  代发总金额：{{ offinePayDate.shouldPay || '--' }}元
                </td>
              </template>
            </tr>
          </table>
        </div>
        <div id="authorizationSheet" v-if="ifFJ">
          <table class="top-left">
            <tr>
              <td colspan="2" class="sheetTitle">工资发放授权单</td>
            </tr>
            <tr>
              <td colspan="2" class="clearfix">
                <div class="tr-left">
                  <p>{{ offinePayDate.salaryInfo }}</p>
                  <div v-if="isEsUser()" class="tr-left-tip">
                    订单生成时间：{{ offinePayDate.createTime || '--' }}
                  </div>
                  <p>{{ offinePayDate.orderId }}</p>
                </div>
                <div class="tr-right">
                  <div class="tr-right-top clearfix">
                    <div class="tr-right-code fl">
                      <img class="srcCodeImg" :src="srcCode" alt />
                    </div>
                    <div class="tr-right-barCode fl">
                      <img class="barCodeCodeImg" :src="barCode" alt />
                    </div>
                  </div>
                  <div class="tr-right-tip">
                    提示：通过扫描二维码或条形码可快捷获取工资表订单
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="2" class="projectInformation">企业信息</td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                企业名称：{{ offinePayDate.companyName || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                统一社会信用代码：{{ offinePayDate.uscc || '--' }}
              </td>
            </tr>
            <tr>
              <td class="tdLeft">法人姓名：{{ offinePayDate.companyBoss }}</td>
              <td class="tdLeft">
                联系方式：{{ offinePayDate.companyBossTel || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                企业联系人姓名：{{ offinePayDate.transactor || '--' }}
              </td>
            </tr>
            <tr>
              <td colspan="2" class="tdLeft">
                企业本地详细办公地址：{{ offinePayDate.address || '--' }}
              </td>
            </tr>
            <tr>
              <td class="tdLeft">
                专户账号：{{ offinePayDate.account || '--' }}
              </td>
              <td class="tdLeft">
                代发总人数：{{ offinePayDate.shouldCount || '--' }}人
              </td>
            </tr>
            <tr>
              <template v-if="isEsUser()">
                <td class="tdLeft">
                  专户签约状态：<span
                    :style="offinePayDate.signed === 0 ? 'color:red' : ''"
                    >{{
                      offinePayDate.signed === 1 ? '已签约' : '未签约'
                    }}</span
                  >
                </td>
                <td class="tdLeft">
                  代发总金额：{{ offinePayDate.shouldPay || '--' }}元
                </td>
              </template>
              <template v-else>
                <td colspan="2" class="tdLeft">
                  代发总金额：{{ offinePayDate.shouldPay || '--' }}元
                </td>
              </template>
            </tr>
          </table>
        </div>
        <div class="btnContainer">
          <el-button class="commonBut" @click="toSalaryList"
            >返回工资表管理</el-button
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import salaryTopTitle from '@/components/publicCom/salaryTopTitle'
import createSalaryStepJz from '@/components/publicCom/createSalaryStepJz'
import common from '../../kits/common'
export default {
  name: 'onlineAuthorization',
  components: {
    salaryTopTitle,
    createSalaryStepJz,
  },
  data() {
    return {
      activeIndex: 2,
      salaryOperate: 'salaryOperate', //非建工资下载
      salaryExcel: 'salaryExcel', //非建工资模板
      wherePage: '',
      salaryId: '',
      id: '',
      srcCode: '',
      barCode: '',
      offinePayDate: '',
    }
  },
  created() {
    this.salaryId = this.$route.query.salaryId
    this.ifFJ = this.$route.query.ifFJ
    this.id = this.$route.query.sequenceCode
  },
  activated() {
    this.salaryId = this.$route.query.salaryId
    this.ifFJ = this.$route.query.ifFJ
    this.id = this.$route.query.sequenceCode
  },
  mounted() {
    this.getOffinePayDate()
    this.getBarimage()
    this.getQrimage()
  },
  methods: {
    /**
     * @description: 线下代发页面数据
     */
    getOffinePayDate() {
      const vm = this
      let dfUrl
      if (vm.ifFJ) {
        dfUrl = 'api-su/salary/expand/ncustxx'
      } else {
        dfUrl = 'api-su/cs/salary/expand/ustxx'
      }
      vm.axios({
        method: 'post',
        url: dfUrl,
        data: {
          id: vm.salaryId,
        },
      })
        .then((res) => {
          if (!res.data.hasError) {
            vm.offinePayDate = res.data.result
          } else {
            this.$message({
              message: res.data.errorMsg,
              type: 'warning',
            })
          }
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取数据失败',
            type: 'error',
          })
        })
    },
    /**
     * @description: 线下代发页面条形码
     */
    getBarimage() {
      const vm = this
      vm.barCode =
        common.commonApi + 'api-su/cs/salary/expand/barimage?info=' + vm.id
    },
    /**
     * @description: 线下代发页面二维码
     */
    getQrimage() {
      const vm = this
      vm.srcCode =
        common.commonApi + 'api-su/cs/salary/expand/qrimage?info=' + vm.id
    },
    /**
     * @description: 下载工资代发授权单
     */
    downloaDauthorizationForm() {
      this.getPdf('authorizationSheet', '工资代发授权单')
    },
    //返回工资表管理
    toSalaryList() {
      // this.$router.push("/home/salaryDf/companySalaryBatchList");
      if (this.$route.query.wherePage && this.$route.query.wherePage == 'fj') {
        this.$router.push('/home/salary/qySalaryList')
        this.$store.commit('CHANGE_SLIDER_NAME', {
          oldUrl: '/home/salary/qySalaryList',
          newUrl: this.$router.currentRoute.fullPath,
        })
      } else {
        this.$router.push({
          path: '/home/salaryDf/companySalaryBatchList',
          name: 'companySalaryBatchList',
          query: {
            projectId: this.$route.query.projectId,
            // projectName:this.projectName,
          },
        })
        this.$store.commit('CHANGE_SLIDER_NAME', {
          oldUrl: '/home/salaryDf/companySalaryBatchList',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
    },
  },
}
</script>

<style scoped lang="less">
.mainCon {
  top: 198px;
  color: #666;
  font-size: 14px;
  .vessel {
    text-align: center;
    margin-top: 60px;
    .reportTitle {
      font-size: 28px;
      color: #009588;
      margin: 36px 0;
    }
    .iconyiqueren {
      font-size: 29px;
      color: #009588;
    }
    .reportWrap {
      padding: 20px 48px;
      margin: 0 auto;
      width: 700px;
      background: #f5f7fb;
      .secondpa {
        margin: 12px 0;
      }
      .canotPay {
        color: #e02020;
      }
    }
    .numStyle {
      color: #009588;
      font-weight: bold;
    }
    .accountPay {
      color: #f78b00;
      font-weight: bold;
    }
    .btnContainer {
      padding-top: 22px;
      margin-top: 24px;
    }
  }
}

#authorizationSheet {
  width: 720px;
  height: 413px;
  text-align: center;
  margin: auto;
  .sheetTitle {
    font-family: SourceHanSansCN-Medium;
    font-size: 24px;
    color: #1f803b;
    background-color: #eaf6ec;
  }

  .top-left {
    width: 720px;
    height: 413px;
    border: 1px solid #1f803b;
    border-collapse: collapse;
    td {
      border: 1px solid #1f803b;
    }
  }
}
.top-title {
  width: 720px;
  height: 33px;
  display: inline-block;
  text-align: right;
}
.tr-left {
  float: left;
  font-family: SourceHanSansCN-Bold;
  font-size: 20px;
  color: #218b3d;
  margin-left: 10px;
  position: relative;
  p:first-child {
    padding: 10px.0;
  }
  p:last-child {
    width: 340px;
    height: 51px;
    line-height: 51px;
    font-family: SourceHanSansCN-Bold;
    font-size: 30px;
    color: #1f803b;
    background: #eaf6ec;
  }
  .tr-left-tip {
    font-family: SourceHanSansCN-Regular;
    font-size: 14px;
    color: #1f803b;
    line-height: 14px;
    position: absolute;
    bottom: -20px;
    left: 10px;
  }
}
.tr-right {
  float: left;
  margin-left: 70px;
  &-top {
    width: 291px;
    // height: 66.4px;
    // margin-top: 10px;
  }
  &-tip {
    font-family: SourceHanSansCN-Regular;
    font-size: 12px;
    color: #333333;
    // margin-top: 10px;
    line-height: 14px;
  }
  &-code {
    width: 100px;
    height: 100px;
  }
  &-barCode {
    width: 160px;
    height: 58px;
    margin-top: 20px;

    margin-left: 17.7px;
  }
}
.projectInformation {
  background: #eaf6ec;
  font-family: SourceHanSansCN-Medium;
  font-size: 14px;
  color: #1f803b;
}
.tdLeft {
  padding-left: 20px;
  text-align: left;
  font-family: SourceHanSansCN-Regular;
  font-size: 14px;
  color: #1f803b;
}
.srcCodeImg {
  width: 100%;
  height: 100%;
}
.barCodeCodeImg {
  width: 100%;
  height: 100%;
}
</style>
